home *** CD-ROM | disk | FTP | other *** search
- import java.util.Hashtable;
- import java.util.Vector;
- import javax.microedition.lcdui.Image;
- import javax.microedition.rms.RecordComparator;
- import javax.microedition.rms.RecordEnumeration;
- import javax.microedition.rms.RecordFilter;
- import javax.microedition.rms.RecordStore;
-
- class CostManager$CostManagerEngine {
- private RecordStore typesRS;
- private RecordStore costsRS;
- private Vector typesVec;
- // $FF: synthetic field
- private final CostManager this$0;
-
- CostManager$CostManagerEngine(CostManager this$0) throws Exception {
- this.this$0 = this$0;
- this.typesRS = RecordStore.openRecordStore("typesRS", true);
- this.costsRS = RecordStore.openRecordStore("costsRS", true);
- this.typesVec = new Vector();
- this.initTypesVec();
- this.updateTypesArray();
- }
-
- Hashtable getCosts() {
- Hashtable mapy = new Hashtable();
- RecordEnumeration enum = null;
- Cost tempCost = null;
- String typeName = null;
- int typeIndex = 0;
- int typeTotalSum = 0;
-
- try {
- enum = this.costsRS.enumerateRecords((RecordFilter)null, (RecordComparator)null, false);
- int tempId = 0;
- int tempSum = 0;
- long tempTime = 0L;
- long min = CostManager.access$000(this.this$0).getDate().getTime();
- long max = CostManager.access$100(this.this$0).getDate().getTime() + 86400000L;
-
- while(enum.hasNextElement()) {
- tempId = enum.nextRecordId();
- byte[] data = this.costsRS.getRecord(tempId);
- tempCost = new Cost(data);
- tempSum = tempCost.getSum();
- typeName = tempCost.getType();
- tempTime = tempCost.getTime();
- if (tempTime >= min && tempTime <= max) {
- if (mapy.containsKey(typeName)) {
- System.out.println("add to report : " + tempCost);
- mapy.put(typeName, new Integer((Integer)mapy.get(typeName) + tempSum));
- } else {
- System.out.println("(first)add to report : " + tempCost);
- mapy.put(typeName, new Integer(tempCost.getSum()));
- }
- } else {
- System.out.println("not pass the time condition");
- }
- }
- } catch (Exception var16) {
- ((Throwable)var16).printStackTrace();
- }
-
- return mapy;
- }
-
- void delAllCosts() throws Exception {
- System.out.println("within delAllCosts()");
- this.costsRS.closeRecordStore();
- RecordStore.deleteRecordStore("costsRS");
- this.costsRS = RecordStore.openRecordStore("costsRS", true);
- }
-
- void addCost(Cost newCost) throws Exception {
- byte[] vec = newCost.toBytes();
- this.costsRS.addRecord(vec, 0, vec.length);
- }
-
- void updateTypesArray() {
- String[] vec = new String[this.typesVec.size()];
-
- for(int i = 0; i < vec.length; ++i) {
- vec[i] = ((Type)this.typesVec.elementAt(i)).getName();
- }
-
- CostManager.access$202(this.this$0, vec);
- }
-
- void initTypesVec() {
- RecordEnumeration enum = null;
-
- try {
- enum = this.typesRS.enumerateRecords((RecordFilter)null, (RecordComparator)null, false);
- int tempId = 0;
-
- while(enum.hasNextElement()) {
- tempId = enum.nextRecordId();
- byte[] data = this.typesRS.getRecord(tempId);
- this.typesVec.addElement(new Type(data));
- }
- } catch (Exception var4) {
- ((Throwable)var4).printStackTrace();
- }
-
- }
-
- void addType(Type type) throws Exception {
- byte[] temp = type.toBytes();
- int idTemp = this.typesRS.addRecord(temp, 0, temp.length);
- type.setId(idTemp);
- this.typesVec.addElement(type);
- CostManager.access$300(this.this$0).append(type.getName(), (Image)null);
- CostManager.access$400(this.this$0).append(type.getName(), (Image)null);
- }
-
- void removeTypeByName(String str) {
- int recordId = 0;
-
- for(int i = 0; i < this.typesVec.size(); ++i) {
- System.out.println("i=" + i);
- if (((Type)this.typesVec.elementAt(i)).getName().equals(str)) {
- recordId = i;
- }
- }
-
- try {
- this.typesRS.deleteRecord(recordId);
- } catch (Exception var5) {
- ((Throwable)var5).printStackTrace();
- }
-
- }
- }
-